package leetcode;

import java.util.Arrays;

/**
 * 描述:455. 分发饼干
 *
 * @author Madison You
 * @created 22:21
 */
public class Easy_455_FindContentChildren {
    public static void main(String[] args) {
        System.out.println(new Easy_455_FindContentChildren().findContentChildren(new int[]{7,8,9,10}, new int[]{5,6,7,8}));
    }

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int i = 0;
        int j = 0;
        int x = 0;
        while (j != s.length && i != g.length) {
            if (s[j] >= g[i]) {
                j++;
                i++;
                x++;
            } else {
                j++;
            }
        }
        return x;
    }
}
